//引入util js
var _util = require('util/util.js');

//other_service
var _other_service = {
    //查询所有用户信息(分类)
    getalluser : function(pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/user/users/query/pages/" +pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    //按用户名查询用户信息（分页）
    getusersby : function(useranme,pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/user/"+username+"/users/query/pages/"+pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    //修改用户账号启用状态
    modifyUserStatus: function(username,available,resolve,reject) {
        _util.request({
            url     : _util.getServerURL("/admin/user/"+username+"/users?available="+available),
            method  : 'PUT',
            success : resolve,
            error   : reject,
        });
    },
    //删除用户账号
    deleteUserAccount: function(username,resolve,reject) {
      _util.request({
          url     : _util.getServerURL("/admin/user/"+username+"/users"),
          method  : 'DELETE',
          success : resolve,
          error   : reject,
      })
    },
    //获取所有的卖家用户信息（分页）
    getAllSeller : function(pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/account/sellers/pages/"+pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    //按卖家名搜索卖家用户信息（分页）
    getAllSellerBy : function(username,pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/account/sellers/"+username+"/pages/"+pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    //修改卖家账号启用状态
    modifySellerStatus : function(username,available,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/account/sellers/"+username+"?available="+available),
            method  : 'PUT',
            success : resolve,
            error   : reject,
        })
    },
    deleteSellerAccount : function(username,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/account/sellers/"+username),
            method  : 'DELETE',
            success : resolve,
            error   : reject,
        });
    },
    getAllShops : function(pagesize,pageid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/shop/shops/pages"+pagesize+"/"+pageid),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    getShopsBy : function(pagesize,pageid,shopname,sellername,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/shop/shops/pages/"+pagesize+"/"+pageid+"?shopname="+shopname+"&sellername="+sellername),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    //修改店铺封禁状态
    modifyShopStatus : function(shopid,available,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/shop/shops/"+shopid+"?available="+available),
            method  : 'PUT',
            success : resolve,
            error   : reject,
        });
    },
    //删除店铺
    deleteShop : function(shopid,resolve,reject){
        _util.request({
            url     : _util.getServerURL("/admin/shop/shops/"+shopid),
            method  : 'DELETE',
            success : resolve,
            error   : reject,
        });
    },
}

//导出
module.exports = _other_service;